home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2001 May / SGI Freeware 2001 May - Disc 1.iso / dist / fw_qt.idb / usr / freeware / include / qpaintdevice.h.z / qpaintdevice.h
C/C++ Source or Header  |  2001-04-12  |  10KB  |  352 lines

  1. /****************************************************************************
  2. ** $Id: qt/src/kernel/qpaintdevice.h   2.3.0   edited 2001-01-26 $
  3. **
  4. ** Definition of QPaintDevice class
  5. **
  6. ** Created : 940721
  7. **
  8. ** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
  9. **
  10. ** This file is part of the kernel module of the Qt GUI Toolkit.
  11. **
  12. ** This file may be distributed under the terms of the Q Public License
  13. ** as defined by Trolltech AS of Norway and appearing in the file
  14. ** LICENSE.QPL included in the packaging of this file.
  15. **
  16. ** This file may be distributed and/or modified under the terms of the
  17. ** GNU General Public License version 2 as published by the Free Software
  18. ** Foundation and appearing in the file LICENSE.GPL included in the
  19. ** packaging of this file.
  20. **
  21. ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
  22. ** licenses may use this file in accordance with the Qt Commercial License
  23. ** Agreement provided with the Software.
  24. **
  25. ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  26. ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  27. **
  28. ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
  29. **   information about Qt Commercial License Agreements.
  30. ** See http://www.trolltech.com/qpl/ for QPL licensing information.
  31. ** See http://www.trolltech.com/gpl/ for GPL licensing information.
  32. **
  33. ** Contact info@trolltech.com if any conditions of this licensing are
  34. ** not clear to you.
  35. **
  36. **********************************************************************/
  37.  
  38. #ifndef QPAINTDEVICE_H
  39. #define QPAINTDEVICE_H
  40.  
  41. #ifndef QT_H
  42. #include "qwindowdefs.h"
  43. #include "qrect.h"
  44. #endif // QT_H
  45.  
  46. #if defined(_WS_QWS_)
  47. class QWSDisplay;
  48. class QGfx;
  49. #endif
  50.  
  51. class QIODevice;
  52. class QString;
  53.  
  54.  
  55. #if defined(_WS_X11_)
  56. struct QPaintDeviceX11Data;
  57. #endif
  58.  
  59. union QPDevCmdParam {
  60.     int             ival;
  61.     int            *ivec;
  62.     QString            *str;
  63.     const QPoint    *point;
  64.     const QRect        *rect;
  65.     const QPointArray    *ptarr;
  66.     const QPixmap    *pixmap;
  67.     const QImage    *image;
  68.     const QColor    *color;
  69.     const QFont        *font;
  70.     const QPen        *pen;
  71.     const QBrush    *brush;
  72.     const QRegion    *rgn;
  73.     const QWMatrix    *matrix;
  74.     QIODevice        *device;
  75. };
  76.  
  77.  
  78.  
  79. class Q_EXPORT QPaintDevice                // device for QPainter
  80. {
  81. public:
  82.     virtual ~QPaintDevice();
  83.  
  84.     int        devType() const;
  85.     bool    isExtDev() const;
  86.     bool    paintingActive() const;
  87.  
  88.     // Windows:      get device context
  89.     // X-Windows: get drawable
  90. #if defined(_WS_WIN_)
  91.     HDC        handle() const;
  92. #elif defined(_WS_X11_)
  93.     HANDLE    handle() const;
  94. #elif defined(_WS_MAC_)
  95.     HANDLE      handle() const;
  96. #elif defined(_WS_QWS_)
  97.     HANDLE      handle() const;
  98. #endif
  99.  
  100. #if defined(_WS_X11_)
  101.     Display        *x11Display() const;
  102.     int            x11Screen() const;
  103.     int            x11Depth() const;
  104.     int            x11Cells() const;
  105.     HANDLE        x11Colormap() const;
  106.     bool        x11DefaultColormap() const;
  107.     void       *x11Visual() const;
  108.     bool        x11DefaultVisual() const;
  109.  
  110.     static Display *x11AppDisplay();
  111.     static int        x11AppScreen();
  112.     static int        x11AppDepth();
  113.     static int        x11AppCells();
  114.     static int        x11AppDpiX();
  115.     static int        x11AppDpiY();
  116.     static HANDLE   x11AppColormap();
  117.     static bool     x11AppDefaultColormap();
  118.     static void    *x11AppVisual();
  119.     static bool        x11AppDefaultVisual();
  120.     static void        x11SetAppDpiX(int);
  121.     static void        x11SetAppDpiY(int);
  122. #endif
  123.  
  124. #if defined(_WS_QWS_)
  125.     static QWSDisplay *qwsDisplay();
  126.     virtual unsigned char * scanLine(int) const;
  127.     virtual int bytesPerLine() const;
  128.     virtual QGfx * graphicsContext(bool clip_children=TRUE) const;
  129. #endif
  130.  
  131.     enum PDevCmd {
  132.     PdcNOP = 0, //  <void>
  133.     PdcDrawPoint = 1, // point
  134.     PdcDrawFirst = PdcDrawPoint,
  135.     PdcMoveTo = 2, // point
  136.     PdcLineTo = 3, // point
  137.     PdcDrawLine = 4, // point,point
  138.     PdcDrawRect = 5, // rect
  139.     PdcDrawRoundRect = 6, // rect,ival,ival
  140.     PdcDrawEllipse = 7, // rect
  141.     PdcDrawArc = 8, // rect,ival,ival
  142.     PdcDrawPie = 9, // rect,ival,ival
  143.     PdcDrawChord = 10, // rect,ival,ival
  144.     PdcDrawLineSegments = 11, // ptarr
  145.     PdcDrawPolyline = 12, // ptarr
  146.     PdcDrawPolygon = 13, // ptarr,ival
  147.     PdcDrawQuadBezier = 14, // ptarr
  148.     PdcDrawText = 15, // point,str
  149.     PdcDrawTextFormatted = 16, // rect,ival,str
  150.     PdcDrawPixmap = 17, // point,pixmap
  151.     PdcDrawImage = 18, // point,image
  152.     PdcDrawText2 = 19, // point,str
  153.     PdcDrawText2Formatted = 20, // rect,ival,str
  154.     PdcDrawLast = PdcDrawText2Formatted,
  155.  
  156.     // no painting commands below PdcDrawLast.
  157.  
  158.     PdcBegin = 30, //  <void>
  159.     PdcEnd = 31, //  <void>
  160.     PdcSave = 32, //  <void>
  161.     PdcRestore = 33, //  <void>
  162.     PdcSetdev = 34, // device - PRIVATE
  163.     PdcSetBkColor = 40, // color
  164.     PdcSetBkMode = 41, // ival
  165.     PdcSetROP = 42, // ival
  166.     PdcSetBrushOrigin = 43, // point
  167.     PdcSetFont = 45, // font
  168.     PdcSetPen = 46, // pen
  169.     PdcSetBrush = 47, // brush
  170.     PdcSetTabStops = 48, // ival
  171.     PdcSetTabArray = 49, // ival,ivec
  172.     PdcSetUnit = 50, // ival
  173.     PdcSetVXform = 51, // ival
  174.     PdcSetWindow = 52, // rect
  175.     PdcSetViewport = 53, // rect
  176.     PdcSetWXform = 54, // ival
  177.     PdcSetWMatrix = 55, // matrix,ival
  178.     PdcSaveWMatrix = 56,
  179.     PdcRestoreWMatrix = 57,
  180.     PdcSetClip = 60, // ival
  181.     PdcSetClipRegion = 61, // rgn
  182.  
  183.     PdcReservedStart = 0, // codes 0-199 are reserved
  184.     PdcReservedStop = 199 //   for Qt
  185.     };
  186.  
  187. protected:
  188.     QPaintDevice( uint devflags );
  189.  
  190. #if defined(_WS_WIN_)
  191.     HDC        hdc;                // device context
  192. #elif defined(_WS_X11_)
  193.     HANDLE    hd;                // handle to drawable
  194.     void         copyX11Data( const QPaintDevice * );
  195.     virtual void     setX11Data( const QPaintDeviceX11Data* );
  196.     QPaintDeviceX11Data* getX11Data( bool def=FALSE ) const;
  197. #elif defined(_WS_MAC_)
  198.     void * hd;
  199.     virtual void fixport();
  200. #elif defined(_WS_QWS_)
  201.     HANDLE hd;
  202. #endif
  203.  
  204.     virtual bool cmd( int, QPainter *, QPDevCmdParam * );
  205.     virtual int     metric( int ) const;
  206.     virtual int     fontMet( QFont *, int, const char * = 0, int = 0 ) const;
  207.     virtual int     fontInf( QFont *, int ) const;
  208.  
  209.     ushort    devFlags;            // device flags
  210.     ushort    painters;            // refcount
  211.  
  212.     friend class QPainter;
  213.     friend class QPaintDeviceMetrics;
  214.     friend Q_EXPORT void bitBlt( QPaintDevice *, int, int,
  215.                  const QPaintDevice *,
  216.                  int, int, int, int, Qt::RasterOp, bool );
  217. #if defined(_WS_X11_)
  218.     friend void qt_init_internal( int *, char **, Display * );
  219. #endif
  220.  
  221. private:
  222. #if defined(_WS_X11_)
  223.     static Display *x_appdisplay;
  224.     static int        x_appscreen;
  225.     static int        x_appdepth;
  226.     static int        x_appcells;
  227.     static HANDLE   x_appcolormap;
  228.     static bool        x_appdefcolormap;
  229.     static void       *x_appvisual;
  230.     static bool     x_appdefvisual;
  231.  
  232.     QPaintDeviceX11Data* x11Data;
  233. #endif
  234.  
  235. private:    // Disabled copy constructor and operator=
  236. #if defined(Q_DISABLE_COPY)
  237.     QPaintDevice( const QPaintDevice & );
  238.     QPaintDevice &operator=( const QPaintDevice & );
  239. #endif
  240. };
  241.  
  242.  
  243. Q_EXPORT
  244. void bitBlt( QPaintDevice *dst, int dx, int dy,
  245.          const QPaintDevice *src, int sx=0, int sy=0, int sw=-1, int sh=-1,
  246.          Qt::RasterOp = Qt::CopyROP, bool ignoreMask=FALSE );
  247.  
  248. Q_EXPORT
  249. void bitBlt( QPaintDevice *dst, int dx, int dy,
  250.          const QImage *src, int sx=0, int sy=0, int sw=-1, int sh=-1,
  251.          int conversion_flags=0 );
  252.  
  253.  
  254. #if defined(_WS_X11_)
  255.  
  256. struct Q_EXPORT QPaintDeviceX11Data {
  257.     Display*    x_display;
  258.     int        x_screen;
  259.     int        x_depth;
  260.     int        x_cells;
  261.     HANDLE    x_colormap;
  262.     bool    x_defcolormap;
  263.     void*    x_visual;
  264.     bool    x_defvisual;
  265. };
  266.  
  267. #endif
  268.  
  269. /*****************************************************************************
  270.   Inline functions
  271.  *****************************************************************************/
  272.  
  273. inline int QPaintDevice::devType() const
  274. { return devFlags & QInternal::DeviceTypeMask; }
  275.  
  276. inline bool QPaintDevice::isExtDev() const
  277. { return (devFlags & QInternal::ExternalDevice) != 0; }
  278.  
  279. inline bool QPaintDevice::paintingActive() const
  280. { return painters != 0; }
  281.  
  282. #if defined(_WS_WIN_)
  283. inline HDC    QPaintDevice::handle() const { return hdc; }
  284. #elif defined(_WS_X11_)
  285. inline HANDLE QPaintDevice::handle() const { return hd; }
  286. #endif
  287.  
  288. #if defined(_WS_X11_)
  289. inline Display *QPaintDevice::x11Display() const
  290. { return x11Data ? x11Data->x_display : x_appdisplay; }
  291.  
  292. inline int QPaintDevice::x11Screen() const
  293. { return x11Data ? x11Data->x_screen : x_appscreen; }
  294.  
  295. inline int QPaintDevice::x11Depth() const
  296. { return x11Data ? x11Data->x_depth : x_appdepth; }
  297.  
  298. inline int QPaintDevice::x11Cells() const
  299. { return x11Data ? x11Data->x_cells : x_appcells; }
  300.  
  301. inline HANDLE QPaintDevice::x11Colormap() const
  302. { return x11Data ? x11Data->x_colormap : x_appcolormap; }
  303.  
  304. inline bool QPaintDevice::x11DefaultColormap() const
  305. { return x11Data ? x11Data->x_defcolormap : x_appdefcolormap; }
  306.  
  307. inline void *QPaintDevice::x11Visual() const
  308. { return x11Data ? x11Data->x_visual : x_appvisual; }
  309.  
  310. inline bool QPaintDevice::x11DefaultVisual() const
  311. { return x11Data ? x11Data->x_defvisual : x_appdefvisual; }
  312.  
  313. inline Display *QPaintDevice::x11AppDisplay()
  314. { return x_appdisplay; }
  315.  
  316. inline int QPaintDevice::x11AppScreen()
  317. { return x_appscreen; }
  318.  
  319. inline int QPaintDevice::x11AppDepth()
  320. { return x_appdepth; }
  321.  
  322. inline int QPaintDevice::x11AppCells()
  323. { return x_appcells; }
  324.  
  325. inline HANDLE QPaintDevice::x11AppColormap()
  326. { return x_appcolormap; }
  327.  
  328. inline bool QPaintDevice::x11AppDefaultColormap()
  329. { return x_appdefcolormap; }
  330.  
  331. inline void *QPaintDevice::x11AppVisual()
  332. { return x_appvisual; }
  333.  
  334. inline bool QPaintDevice::x11AppDefaultVisual()
  335. { return x_appdefvisual; }
  336. #endif // _WS_X11_
  337.  
  338.  
  339. Q_EXPORT
  340. inline void bitBlt( QPaintDevice *dst, const QPoint &dp,
  341.             const QPaintDevice *src, const QRect &sr =QRect(0,0,-1,-1),
  342.             Qt::RasterOp rop=Qt::CopyROP, bool ignoreMask=FALSE )
  343. {
  344.     bitBlt( dst, dp.x(), dp.y(), src, sr.x(), sr.y(), sr.width(), sr.height(),
  345.         rop, ignoreMask );
  346. }
  347.  
  348.  
  349.  
  350.  
  351. #endif // QPAINTDEVICE_H
  352.